/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;

import javax.inject.Inject;
import javax.inject.Named;
import mail.EmailEJB;
import mail.EmailTemplateHelper;
import mail.datamodel.IdDataSource;

/**
 *
 * @author Alvaro
 */
@Named(value = "suggestionsBean")
@SessionScoped
public class SuggestionsBean implements Serializable{
    @Inject
    EmailEJB emailEJB;
    private String email;
    private String name;
    private String content;
    
    public void createNewSuggestion(){
        String subject="[SUGGESTION-WEBSITE]";
        String html=EmailTemplateHelper.getHtmlDivText("Nombre: "+name)+EmailTemplateHelper.getHtmlDivText("Email: "+email)+EmailTemplateHelper.getHtmlDivText("Mensaje: "+content);
        List<IdDataSource> dataSources=new ArrayList<IdDataSource>();
        emailEJB.sendHtmlMail("suggestions@therecruitery.com", subject, html, dataSources);
        resetFields();
    }

    public String createNewSuggestionSmartphone(){
        String subject="[SUGGESTION-WEBSITE]";
        String html=EmailTemplateHelper.getHtmlDivText("Nombre: "+name)+EmailTemplateHelper.getHtmlDivText("Email: "+email)+EmailTemplateHelper.getHtmlDivText("Mensaje: "+content);
        List<IdDataSource> dataSources=new ArrayList<IdDataSource>();
        emailEJB.sendHtmlMail("suggestions@therecruitery.com", subject, html, dataSources);
        resetFields();
        return "index?faces-redirect=true";
    }
    /**
     * @return the email
     */
    
    public void resetFields(){
        email="";
        name="";
        content="";
    }
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }
   

      
            
}
